Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Live Templates #310

Merged
merged 2 commits into from
Aug 15, 2024
Merged

Adding Live Templates #310

merged 2 commits into from
Aug 15, 2024

Conversation

Kantis
Copy link
Member

@Kantis Kantis commented Jun 22, 2024

When a user wants to define a new spec, they can:

  1. Create a Kotlin file (Not class) in the desired location, with the name of the spec they want to define.
  2. In the opened file, use one of the provided live templates. For instance fspec to start defining a FunSpec

fspec expands into:

class MyTest : FunSpec({
   test("Foo") {
      1 shouldBe 1
   }
}

Where MyTest is based on the name of the file, and is the first focused location which lets the user change the Spec name if desired. Pressing tab moves the focus to the name of the test (Foo). The user can change the name then press tab again to focus the test body.

IntelliJ also added an import for FunSpec automatically.

Desired feedback:

What spec styles and abbreviations should we use?

So far I have added:

  • sspec -> StringSpec
    • Perhaps FreeSpec is a better spec to focus on, given that it supports nesting. But I think we might harmonize them and settle on a final name for this style
  • bspec -> BehaviorSpec
  • fspec -> FunSpec
    • This one clashes a bit with FreeSpec and FeatureSpec

Maybe we can dogfood this one in the wild.. not a lot of users would find the feature w/o us advertising it somewhere.

When a user wants to define a new spec, they can:
1. Create a **Kotlin file** (Not class) in the desired location, with the name of the spec they want to define.
2. In the opened file, use one of the provided live templates. For instance `fspec` to start defining a FunSpec

`fspec` expands into:
```kotlin
class MyTest : FunSpec({
   test("Foo") {
      1 shouldBe 1
   }
}
```

Where `MyTest` is based on the name of the file, and is the first focused location which lets the user change the Spec name if desired. Pressing tab moves the focus to the name of the test (`Foo`). The user can change the name then press tab again to focus the test body.

IntelliJ also added an import for FunSpec automatically.

Desired feedback:
---

What spec styles and abbreviations should we use?

So far I have added:
* `sspec` -> StringSpec
  * Perhaps FreeSpec is a better spec to focus on, given that it supports nesting. But I think we might harmonize them and settle on a final name for this style
* `bspec` -> BehaviorSpec
* `fspec` -> FunSpec
  * This one clashes a bit with FreeSpec and FeatureSpec
@Kantis Kantis requested a review from sksamuel June 24, 2024 13:45
@sksamuel
Copy link
Member

could also just have stringspec, saving 5 chars isn't a huge deal

@sksamuel
Copy link
Member

Do we want to merge this in @Kantis ?

@Kantis Kantis merged commit fdb5db6 into master Aug 15, 2024
5 checks passed
@Kantis Kantis deleted the kantis/adding-live-templates branch August 15, 2024 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants